using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter28
{
	/// <summary>
	/// Example01: Terminal Voltage of a Battery
	/// A battery has emf of 12.0 V and an internal resistance 
	/// of 0.05 \Omega. Its terminals are connected to a load 
	/// resistance of 3.00 \Omega.
	/// (A)	
	/// Find the current in the circuit and the terminal voltage 
	/// of the battery.
	/// (B)	
	/// Calculate the power delivered to the load resistor, 
	/// the power delivered to the internal resistance of the 
	/// battery, and the power delivered by the battery.
	/// </summary>
	public class Example01
	{
		public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricPotentialDifference V
				= new L.ElectricPotentialDifference();
			V.V = 12.0;
			L.Resistance R = new L.Resistance();
			R.Ohm = 3.0;
			L.Resistance interR = new L.Resistance();
			interR.Ohm = 0.05;
			//(A)
			L.Resistance Rsum = L.Resistance.Series(R,interR);
			L.ElectricCurrent I = new L.ElectricCurrent(Rsum,V);
			result+=Convert.ToString(I.A)+"\r\n"; 
			result+=Convert.ToString(V.V - interR.Ohm*I.A)+"\r\n"; 
			//(B)
			L.ElectricPower P = new L.ElectricPower(R,I);
			result+=Convert.ToString(P.W)+"\r\n"; 
			L.ElectricPower P2 = new L.ElectricPower(interR,I);
			result+=Convert.ToString(P2.W)+"\r\n"; 
			L.ElectricPower P3 = new L.ElectricPower(I,V);
			result+=Convert.ToString(P3.W)+"\r\n"; 
			result+=Convert.ToString(P.W+P2.W)+"\r\n"; 
		}
	}
}
